package main

import (
	"fmt"
	"github.com/gomodule/redigo/redis"
)

// 定义全局的pool
var pool *redis.Pool

func main() {
	c := pool.Get()
	defer c.Close()
	str, err := redis.String(c.Do("Get", "test1"))
	if err != nil {
		fmt.Printf("get test1 err: %v", err)
	}
	fmt.Println(str)
}

func init() {
	pool = &redis.Pool{
		MaxIdle:     10,
		MaxActive:   0,
		IdleTimeout: 100,
		Dial: func() (redis.Conn, error) {
			return redis.Dial("tcp", "0.0.0.0:6379")
		},
	}
}
